home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
vbtbox
/
parent.frm
< prev
next >
Wrap
Text File
|
1995-05-07
|
2KB
|
67 lines
VERSION 2.00
Begin Form Parent
Caption = "Parent"
ClientHeight = 1965
ClientLeft = 1305
ClientTop = 1740
ClientWidth = 4095
Height = 2655
Left = 1245
LinkTopic = "Form1"
ScaleHeight = 1965
ScaleWidth = 4095
Top = 1110
Width = 4215
WindowState = 2 'Maximized
Begin Menu Showtbox
Caption = "&Show Toolbox"
End
Begin Menu Exit
Caption = "&Exit"
End
End
Option Explicit
'This is a simple demo of how to do a
'floating toolbox in VB as requested
'by a few people on the VISBAS-L
'mailing list.
'Hope this is of use to someone
'Matthew Dexter (ch01md@surrey.ac.uk)
'Declare SetParent API function
Declare Function SetParent% Lib "User" (ByVal hWndChild%, ByVal hWndNewParent%)
Dim doshow As Integer 'Boolean to decide if toolbox is hidden or shown
Sub Exit_Click ()
'quit program
Unload Me
End Sub
Sub Form_Load ()
doshow = False 'initially toolbox is not shown
Load tbox 'toolbox is loaded but not yet shown
End Sub
Sub Form_QueryUnload (Cancel As Integer, UnloadMode As Integer)
Unload tbox 'essential or else VB will crash!!!
End Sub
Sub ShowTbox_Click ()
Dim ret As Integer
If doshow = False Then 'toolbox not visible
ret = SetParent(tbox.hWnd, parent.hWnd) 'this makes the toolbox float
tbox.Left = 0 'sets position to top left corner of parent
tbox.Top = 0
tbox.Show 'makes toolbox visible
'try tbox.show 1 i.e. modal to see what happens
doshow = True
Showtbox.Caption = "&Hide Toolbox"
Else
tbox.Hide
doshow = False
Showtbox.Caption = "&Show Toolbox"
End If
End Sub